<%--
    Document   : upload
    Created on : Apr 30, 2013, 11:18:10 AM
    Author     : zulfadli
--%>
<%@ include file="/WEB-INF/jsp/include/page_header.jspf" %>
<%@ taglib prefix="display" uri="http://displaytag.sf.net"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <link rel="stylesheet" href="${pageContext.request.contextPath}/css/ui-lightness/jquery-ui-1.10.2.custom.css" />
        <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-ui-1.10.2.custom.js"></script>
        <script type="text/javascript">
            $(function() {
                $("#date").datepicker();
            });
            
            function validateFirst(){
                var validate = true;
                var message = "All field are required";
                if($("#vesselId").val()=='') validate = false;
                if($("#file").val()=='') validate = false;
                if($("#caption").val()=='') validate = false;
                if($("#year").val()=='') validate = false;
                if($("#month").val()=='') validate = false;
                if(validate==false) alert(message);
                return validate;
            }
        </script>
    </head>
    <body>
        <s:errors />
        <s:messages />
        <div id="page-title">
            <span class="title">Upload Photo</span><label>&nbsp;</label><label>&nbsp;</label>
            <br>
        </div>
        <s:useActionBean beanclass="exatrez.stripes.util.ListUtil" var="list"/>
        <s:form beanclass="exatrez.stripes.action.GalleryAction" name="form1">
            <div>
                <fieldset>
                    <!--<legend>General</legend>-->
                    <p>
                        <label>Vessel</label>
                        <s:select name="picture.vessel.vesselId" id="vesselId" style="width:150px">
                            <s:option value="">Please Choose</s:option>
                            <s:options-collection collection="${list.vesselList}" label="vesselName" value="vesselId"/>
                        </s:select>
                    </p>
                    <p>
                        <label>Picture</label>
                        <s:file name="fileBean" id="file" />
                    </p>
                    <p>
                        <label>Caption</label>
                        <s:textarea name="picture.caption" id="caption" cols="40" rows="3" />
                    </p>                    
                    <p>
                        <label>Year Taken</label>
                        <jsp:useBean id="date" class="java.util.Date" />
                        <fmt:formatDate value="${date}" pattern="yyyy" var="currentYear" />
                        <s:select name="picture.year" id="year" style="width: 150px;">
                            <s:option value="">Year</s:option>
                            <s:option value="${curentYear}">${currentYear}</s:option>
                            <c:forEach var="i" begin="1" end="5">
                                <s:option value="${currentYear-i}">${currentYear-i}</s:option>
                            </c:forEach>
                        </s:select>
                        <s:select name="month" id="month" style="width: 120px">
                            <s:option value="">Month</s:option>
                            <s:option value="1">January</s:option>
                            <s:option value="2">February</s:option>
                            <s:option value="3">March</s:option>
                            <s:option value="4">April</s:option>
                            <s:option value="5">May</s:option>
                            <s:option value="6">June</s:option>
                            <s:option value="7">July</s:option>
                            <s:option value="8">August</s:option>
                            <s:option value="9">September</s:option>
                            <s:option value="10">October</s:option>
                            <s:option value="11">November</s:option>
                            <s:option value="12">December</s:option>
                        </s:select>
                    </p>
                    <p>
                        <label>&nbsp;</label>                        
                        <s:submit class="btn" name="index" value="Back" />
                        <s:submit class="btn" name="uploadImage" value="Upload" onclick="return validateFirst()"/>
                    </p>
                </fieldset>
            </div>
        </s:form>
    </body>
</html>
